<?php
////////////////////////////////////////////////////////////////////////////
//                                                                        //
// NOTICE OF COPYRIGHT                                                    //
//                                                                        //
// Dean`s Office for Moodle                                               //
// Электронный деканат                                                    //
// <http://deansoffice.ru/>                                               //
//                                                                        //
// Copyright (C) 2008-2999  Alex Djachenko (Алексей Дьяченко)             //
// alex-pub@my-site.ru                                                    //
// This program is free software: you can redistribute it and/or modify   //
// it under the terms of the GNU General Public License as published by   //
// the Free Software Foundation, either version 3 of the Licensen.        //
//                                                                        //
// This program is distributed in the hope that it will be useful,        //
// but WITHOUT ANY WARRANTY; without even the implied warranty of         //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          //
// GNU General Public License for more details.                           //
//                                                                        //
// You should have received a copy of the GNU General Public License      //
// along with this program.  If not, see <http://www.gnu.org/licenses/>.  //
//                                                                        //
////////////////////////////////////////////////////////////////////////////
//  Главная страница гостевой книги
////////////////////////////////////////////////////////////////////////////

// Подключаем библиотеки
require_once('lib.php');
require_once('form.php');
require_once('display.php');
// Проверка доступа к БД
$DOF->storage('posts')->require_access('view');
$DOF->storage('comments')->require_access('view');

// Получаем данные для пагинации
$limitnum     = optional_param('limitnum', $DOF->
            modlib('widgets')->get_limitnum_bydefault(), PARAM_INT);
$limitfrom    = optional_param('limitfrom', '1', PARAM_INT);
$addvars = array('task' => 'add');

// Форма
$customdata = new stdClass;
$customdata->dof = $DOF;
$form = new dof_im_pguestbook_add_form($DOF->url_im(
            'pguestbook','/process_form.php',$addvars),$customdata);

// Список
$list = new dof_im_pguestbook_list($DOF,$addvars); 

// Навигация

$count = $list->count_all();
$pages = $DOF->modlib('widgets')->pages_navigation(
            'pguestbook',$count,$limitnum, $limitfrom);

$vars = array('limitnum'     => $pages->get_current_limitnum(),
              'limitfrom'    => $pages->get_current_limitfrom()
              );
$pagesstring = $pages->get_navpages_list('/index.php', $vars);

/*  Страница  */
$DOF->modlib('nvg')->print_header(NVG_MODE_PORTAL);
$form->display();
if ( $pagesstring )
{
    print '<p align="center">'.$DOF->get_string('pages', 'pguestbook').':<br>'.
    $pagesstring.'</p>';
}
$list->display($limitnum, $limitfrom);
if ( $pagesstring )
{
    print '<p align="center">'.$DOF->get_string('pages', 'pguestbook').':<br>'.
    $pagesstring.'</p>';
}
$DOF->modlib('nvg')->print_footer(NVG_MODE_PORTAL);